package com.claudiushauptmann.gwt.recaptcha.sample.server;

import net.tanesha.recaptcha.ReCaptcha;
import net.tanesha.recaptcha.ReCaptchaFactory;

import com.claudiushauptmann.gwt.recaptcha.sample.client.RecaptchaRemoteService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class RecaptchaRemoteServiceImpl extends RemoteServiceServlet implements
		RecaptchaRemoteService {

	private static final long serialVersionUID = -3280477565969758716L;

	public boolean verifyChallenge(String challenge, String response) {
		ReCaptcha r = ReCaptchaFactory.newReCaptcha("6LeoPwYAAAAAAEgl-99fWvVvzRQObu5UoTPoQtg1",
				"6LeoPwYAAAAAAKTZvk06wA2GyBzDDTQUs39Bh2qC", true);
		return r.checkAnswer(
				getThreadLocalRequest().getRemoteAddr().toString(), challenge,
				response).isValid();
	}

}
